package org.dut.book.model;

import lombok.Data;
import org.dut.book.Enum.ResultStatus;

@Data
public class Result {
    private ResultStatus status;
    private String errorMsg;
    private Object data;

    public static Result success(Object data) {
        Result result = new Result();
        result.setData(data);
        result.setStatus(ResultStatus.SUCCESS);
        result.setErrorMsg(null);
        return result;
    }
    public static Result fail(String errorMsg) {
        Result result = new Result();
        result.setStatus(ResultStatus.FAIL);
        result.setErrorMsg(errorMsg);
        result.setData(null);
        return result;
    }
    public static Result unlogin() {
        Result result = new Result();
        result.setStatus(ResultStatus.UNLOGIN);
        result.setErrorMsg("you are not logged in");
        result.setData(null);
        return result;
    }
//    public static Result fail(ResultStatus resultStatus, String msg){
//        Result result = new Result();
//        result.setStatus(resultStatus);
//        result.setErrorMsg(msg);
//        return result;
//    }
}
